package com.ruoyi.livenuniappserver.api.subscribe.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.livenuniappserver.api.subscribe.domain.Course;
import com.ruoyi.livenuniappserver.api.subscribe.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * @ClassName CourseSubscribeController
 * @Description TODO
 * @Author Lenovo
 * @Date 2024/7/2 10:04
 **/
@RestController
@RequestMapping("/subscribe/courseSubscribe/")
public class CourseController extends BaseController {
    @Autowired
    private CourseService courseSubscribeService;
    /*
    * @Author lzy
    * @Description 查询团课列表及详细信息
    * @Date 2024/7/3 19:18
    * @Return com.ruoyi.common.core.page.TableDataInfo
    * @param id
    */
    @GetMapping("/queryAll")
    public TableDataInfo queryAll(Integer id){
        List<Course> list = courseSubscribeService.selectCourseSubscribeList(id);
        return getDataTable(list);
    }
    /*
    * @Author lzy
    * @Description 报名后添加一条报名记录
    * @Date 2024/7/3 19:31
    * @Return com.ruoyi.common.core.domain.AjaxResult
    * @param course
    */
    @GetMapping("/saveRegistrationRecord")
    private AjaxResult saveRegistrationRecord(String registrationCourseName, Integer courseId, Integer userId){
        int i = courseSubscribeService.saveRegistrationRecord(registrationCourseName,courseId,userId);
        return AjaxResult.success(i);
    }
//    @GetMapping("/insertRecord")
//    private AjaxResult insertRecord(@RequestBody Course course){
//        String registrationCourseName = course.getCourseName();
//        Integer courseId= course.getCouchId();
//        int i = courseSubscribeService.saveRegistrationRecord(registrationCourseName,courseId);
//        return AjaxResult.success(i);
//    }
}
